package com.bowlong.net.proto.gen.proto.demo;

import static com.bowlong.net.proto.gen.B2G.CLIENT;
import static com.bowlong.net.proto.gen.B2G.DATA;
import static com.bowlong.net.proto.gen.B2G.SERVER;

import java.util.List;

import com.bowlong.io.FileEx;
import com.bowlong.net.proto.gen.B2Class;
import com.bowlong.net.proto.gen.B2Field;
import com.bowlong.net.proto.gen.B2G;
import com.bowlong.net.proto.gen.B2Method;
import com.bowlong.net.proto.gen.B2Param;
import com.bowlong.net.proto.gen.Bio2GJava;

/**
 * 服务器通信接口
 * 
 * @author niko
 * 
 */
@B2Class(namespace = "gate")
public class GateService {

	public static void main(String[] args) throws Exception {
		Class<?> c = GateService.class;
		boolean src = FileEx.exists("src");
		Bio2GJava.b2g(c, src);
	}

	// ///////////////////////////////////////////////////

	@B2Class(type = DATA, remark = "返回值")
	class ReturnStatus {
		public int succ;
		public String msg;
	}

	@B2Class(type = DATA, remark = "NGateStr")
	class NGateStr {
		public String msg;
	}

	@B2Class(type = DATA, remark = "数字信息")
	class NGateCodes {
		public List<Integer> codes;
	}

	@B2Class(type = B2G.DATA, remark = "语言", constant = true)
	class GateCodeType {
		@B2Field(remark = "重新加载pb文件", def = "1")
		int LoadPbs = 1;
	}

	@B2Class(type = SERVER)
	interface GateServiceI {
		// 服务器通信接口
		@B2Method(type = SERVER, async = false, params = { "userCount", "host",
				"tcpPort", "resourcesUrl", "lowVer", "nowVer", "key", "codes" }, remark = "提交游戏服务状态")
		ReturnStatus submitLogicStatus(int userCount, String host, int tcpPort,
				String resourcesUrl, String lowVer, String nowVer, String key,
				@B2Param(oType = "NGateCodes", isOut = true) NGateCodes codes);

		@B2Method(type = SERVER, async = false, params = { "val", "outStr" }, remark = "提交游戏服务状态")
		ReturnStatus ping(String val,
				@B2Param(oType = "NGateStr", isOut = true) NGateStr outStr);

		@B2Method(type = CLIENT, async = false, params = { "outStr" }, remark = "提交游戏服务状态")
		void push(@B2Param(oType = "NGateStr", isOut = true) NGateStr outStr);
	}

	// ///////////////////////////////////////////////////
}
